# 选择合适的镜像
FROM ubuntu:bionic

LABEL Maintainer="" \
      Description="Discuz! Q container with Nginx & PHP-FPM based on Ubuntu bionic."

ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=Asia/Shanghai

# 替换包加速更新
RUN sed -i "s/\/\/.*archive.ubuntu.com/\/\/mirrors.aliyun.com/g;s/\/\/.*security.ubuntu.com/\/\/mirrors.aliyun.com/g" /etc/apt/sources.list

RUN apt-get update &&  \
    apt-get install -y tzdata apt-utils && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
    apt-get install -y --no-install-recommends mysql-server ca-certificates php-fpm nginx cron openssl php-mysql php-gd php-bcmath php-mbstring php-xml php-curl php-exif php-zip supervisor && \
    rm -rf /var/lib/apt/lists/* && \
    sed -i '/session    required     pam_loginuid.so/c\#session    required   pam_loginuid.so' /etc/pam.d/cron

RUN mkdir /run/php

COPY root /

RUN chown -R www-data:www-data /var/www/discuz

RUN chmod +x /usr/sbin/*.sh

VOLUME /var/lib/mysql

EXPOSE 80 443

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
